package com.qd.common.panda.domain.entity.collect;

import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.qd.common.panda.domain.entity.carpark.CarParkInfoDTO;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Optional;

/**
 * 用户收藏
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class UserCollectDTO extends BaseQuery {

    /**
     * 主键
     */
    @NotBlank(message = "收藏ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "收藏ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String cid;
    /**
     * 收藏时间
     */
    private LocalDateTime addTime;
    /**
     * 用户唯一标识
     */
    @Size(max = 50, message = "用户唯一标识长度不能超过{max}位", groups = DefaultGroup.class)
    private String userId;
    /**
     * 停车场
     */
    @NotBlank(message = "停车场不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "停车场长度不能超过{max}位", groups = DefaultGroup.class)
    private String parkId;
    /**
     * 停车场显示
     */
    private String parkIdDisplay;

    /**
     * 停车场信息
     */
    private CarParkInfoDTO carParkInfo;

    @Override
    public void freeData() {
        this.cid = null;
        this.addTime = null;
        this.userId = null;
        this.parkId = null;
        this.parkIdDisplay = null;
        Optional.ofNullable(carParkInfo).ifPresent(CarParkInfoDTO::freeData);
        super.freeData();
    }
}
